Support for cross-compiling on Linux#465
Support for cross-compiling on Linux#465universeindex wants to merge 43 commits intosmartcmd:mainfrom
Conversation
…ace all #inlcudes containing backslashes with forward slashes (not supported outside MSVC)
…e in miles sound system, probably the abi blowing up
|
P.S. I tested building on Windows, which still works fine, so hopefully there shouldn't be any issues |
|
Most commits made to upstream will probably conflict with those by overwriting the includes I changed back with backslashes, but I'll be fixing those until this is merged |
|
I tested CMake w/ visual studio generator on Windows (with MSVC) which worked fine, but I haven't tried the normal .sln yet. I can do that now, but it might be a minute, i'm working on a really slow machine currently |
|
works fine, compiles and runs w/ visual studio build ^ |
|
I did rewrite Minecraft.Client/iob_shim.asm in C++ as IobShim.cpp because I couldn't get MASM to work under Linux, but that's it aside from the includes I believe. |
|
can confirm does compile on linux w/ cmake well done :) |
cmake/LinuxCrosscompile.cmake
Outdated
| set(CMAKE_C_COMPILER_FRONTEND_VARIANT MSVC) | ||
| set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT MSVC) | ||
|
|
||
| add_compile_options(/winsysroot /opt/msvc --target=x86_64-pc-windows-msvc -fms-compatibility -fms-extensions -fdelayed-template-parsing) |
There was a problem hiding this comment.
the cmake file assumes /opt/msvc whereas https://github.com/mstorsjo/msvc-wine recommends ~/my_msvc/opt/msvc
just a simple issue as you can syslink or run the msvc-wine installer as root & install to /opt/msvc
There was a problem hiding this comment.
oh, good catch, i think i might set it to CMAKE_BINARY_DIR/msvc so users can symlink one instead, or if theres a way to set options of a toolchain file that would be best
will change soon, not home atm
There was a problem hiding this comment.
msvc-wine sets itself in the path directory (although the user has to set this up manually through something like .zshrc)
could do something like
whereis msbuild
to determine the directory?
if it isn't set as CMAKE_MSVC_DIR
There was a problem hiding this comment.
opened pr on your fork that fixes this & a clang error universeindex#1
…ot with explicit -imsvc paths
|
|
will need someone to test compiling on windows however |
yeah i havent done much c++ for a good few years and thought it still existed, this seems to work though https://github.com/DwifteJB/MinecraftConsoles/blob/ee78a74025b78b0c5c813a7beb7c94629a30c2ff/Minecraft.Client/IobShim.cpp |
|
i got msvc-wine installed do |
|
seems to be an issue with msvc, try this fork/pr https://github.com/DwifteJB/MinecraftConsoles/tree/msvc-winsysroot-fix might just fix it (with branch msvc-winsysroot-fix) |
something like: grabbed from: https://cboard.cprogramming.com/windows-programming/138371-intel-assembly-syntax-gcc.html |
seems to be compiling (at the very least) & seems to be almost identical other than the clang unreachable trap |
yes its that one, Here's a run showcasing it being stuck on the end https://github.com/Twig6943/MinecraftConsoles/actions/runs/22801883533/job/66144749796 |
how ? |
|
Run seems to be stuck https://github.com/DwifteJB/MinecraftConsoles/actions/runs/23008712897/job/66812791427 1294/1296 It builds fine on a local machine but gets stuck on github actions, idk what's up with that. You can just seperate the actions stuff into its own pr as discussed above. Thanks for getting the ball rolling on this btw |
|
seems like it, ill check to see whats going on with it now by running the actions locally |
I meant like just running the commands manually, idk if it'll get stuck or not when using a self hosted runner |
testing with act via a docker compose file (just to see if it runs), might be due to it being in a container, being stuck after stubs is super confusing, so im just making it run on ubuntu itself rather than an arch linux container within it... |
Could be the case ig? I tried fedora and it also got stuck at the same place |
seems to be the only thing that makes sense, may be missing a dependency but i would've thought itd error out |
|
hi sorry for the inactivity, I'll get on helping fix this up later today |
hi! if you read up builds are basically working, fixing build-linux.yml now |
|
testing now, not sure if its due to some issue with wine display or via a race condition occuring & causing a file to be locked... will see |
too many issues with ubuntu & clang, no clue why. even though they ARE installed??? https://github.com/DwifteJB/MinecraftConsoles/actions/workflows/build-linux.yml |
|
@DwifteJB I'm not sure where you got the assumption that it being stuck is related to not having a display
This builds fine which doesn't have a display; https://github.com/nocss42/GardenGate/blob/dedicated/.github/workflows/dll_linux.yml |
assumption since it got stuck on my local machine when i didnt have a display connected |
|
I don't know why it requires a display for this to be built but not gardengate anyways could you convert it to wlheadless-run with cage? (That is once it builds w xvfb lol) for arch it'd be Edit: yea nevermind it seems to be stuck at 1104 with xvfb so won't make a difference |
atp lets ignore the actions file & sort it out in a different pr |
Yea as I said it should be looked into later Shoot that pr and will prob be merged soon |
|
@universeindex universeindex#4 very simple fix inside |
fix: builds & add compile instructions to README








Description
I've implemented support for cross-compiling a Windows build on a Linux host using clang-cl. I added a toolchain file at cmake/LinuxCrosscompile.cmake that achieves this. I also modified many source files to not use backslashes in include statements (which error with clang-cl) and use case-sensitive paths (many Linux filesystems are case-sensitive, unlike NTFS, which causes errors). I avoided changing actual functionality as much as possible, so I hope this isn't too intrusive. Additionally I apologize for the messy commit messages, I hope this isn't a big issue, I have detailed all of the changes I made here.
Changes
Include statements use forward slashes instead of backslashes
Include statements reference files with correct capitalization
Added a CMake toolchain file for using clang-cl on Linux
Minecraft.Client/Xbox/MinecraftWindows.rc is not compiled on Linux, this causes errors otherwise, as it can't find the windows SDK and I am unsure how to specify the location here.
I also added documentation for building on Linux.
Previous Behavior
Running CMake on Linux would throw a hardcoded error stating that Linux isn't supported. When removed, and clang-cl is set to be used, many errors occur due to include paths using backslashes and inconsistent capitalization. The only way to build and run on Linux before is to use a Windows VM, and there is no way to get proper code completion on a Linux IDE.
Root Cause
Backslashes in include paths are supported on Windows, but not other systems, and NTFS is case-insensitive, so include paths do not have to match capitalization, also not on other systems.
New Behavior
The game now compiles and outputs a Windows binary on Linux using clang-cl.
Fix Implementation
See changes section